home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 1 / Amiga Tools.iso / egs-tools / egs_demo-version / egs_devels / c-include / egslayers.h < prev    next >
C/C++ Source or Header  |  1994-06-06  |  12KB  |  313 lines

  1. #ifndef EGS_EGSLAYERS_H
  2. #define EGS_EGSLAYERS_H
  3.  
  4. /***************************************************************************\
  5. *  $
  6. *  $ FILE     : egslayers.h
  7. *  $ VERSION  : 1
  8. *  $ REVISION : 1
  9. *  $ DATE     : 02-Feb-93 19:48
  10. *  $
  11. *  $ Author   : mvk
  12. *  $
  13. *
  14. *****************************************************************************
  15. *                                                                           *
  16. * (c) Copyright 1990/93 VIONA Development                                   *
  17. *     All Rights Reserved                                                   *
  18. *                                                                           *
  19. \***************************************************************************/
  20.  
  21. #ifndef         EXEC_TYPES_H
  22. #include        <exec/types.h>
  23. #endif
  24. #ifndef         EXEC_PORTS_H
  25. #include        <exec/ports.h>
  26. #endif
  27. #ifndef         EXEC_LISTS_H
  28. #include        <exec/lists.h>
  29. #endif
  30. #ifndef         EXEC_SEMAPHORES_H
  31. #include        <exec/semaphores.h>
  32. #endif
  33. #ifndef         EGS_EGS_H
  34. #include        <egs/egs.h>
  35. #endif
  36. #ifndef         EGS_EGSBLIT_H
  37. #include        <egs/egsblit.h>
  38. #endif
  39.  
  40.  
  41.  
  42. /*
  43.  * This library manages overlapping, independent, rectangular screen areas
  44.  * (layers).  They form the base of each window system.
  45.  *
  46.  * Layers can be moved, sized and put from front to back or vice versa.  The
  47.  * library offers adequate functions.  Areas to be clipped, hidden and
  48.  * restored are held in lists of "ClipRects".  That structure is defined in
  49.  * EGSBlit so there are no complications for clipping.
  50.  *
  51.  * Currently four kinds of Layers are supported:
  52.  *
  53.  * - no care refresh : Layer parts hidden by other layers are never refreshed.
  54.  *                     No list of rectangles to be refreshed is kept.
  55.  *                     This layer kind is recommended if the layer's contents
  56.  *                     are automatically refreshed in constant intervals,
  57.  *                     e.g. for animation.
  58.  *
  59.  * - simple refresh  : The library keeps a list which contains the parts that
  60.  *                     need refreshing.  If this list changes, i.e. if refresh
  61.  *                     is needed, an appropriate message is sent to a given
  62.  *                     port.
  63.  *                     Then the program should refresh its display.  For this,
  64.  *                     "BeginRefresh" and "EndRefresh" claim the part to be
  65.  *                     refreshed as the current drawing area so that only the
  66.  *                     damaged screen parts are drawn into during refresh.
  67.  *                     This layer kind is the best compromise between memory
  68.  *                     usage and execution speed.  It should be used whenever
  69.  *                     possible since layers saving their hidden parts eat
  70.  *                     a lot of memory in high resolution graphics.
  71.  *
  72.  * - super bitmap    : These layers own a Bitmap that can greatly exceed the
  73.  *                     visible portion.  The layer forms a window over this
  74.  *                     BitMap that you may move as you like.  Damaged screen
  75.  *                     areas are refreshed by restoring them with data from
  76.  *                     this special background BitMap.  This layer's disad-
  77.  *                     vantage is the gigantic memory requirement.  You should
  78.  *                     use them only if really necessary, e.g. pixel oriented
  79.  *                     graphics.
  80.  *
  81.  * - smart refresh   : For all obscured areas, these layers create restoring
  82.  *                     areas which are managed dynamically and are later
  83.  *                     freed automatically.
  84.  *                     So you need not pay attention to refresh as drawing
  85.  *                     operations are performed even in these restoring areas.
  86.  *                     But a refresh message is sent as soon as the layer is
  87.  *                     sized.
  88.  *                     The disadvantage of this layer is its gigantic memory
  89.  *                     usage especially for big bit depths.  You should
  90.  *                     use this type in such screens scarcely.
  91.  */
  92.  
  93.  
  94.  
  95. /*
  96.  * LayerFlags, LayerFlagSet
  97.  *
  98.  * - SIMPLE_REFRESH  : Set if "simple refresh layer".
  99.  * - SUPER_BITMAP    : Set if "super bitmap layer".
  100.  * - SMART_REFRESH   : Set if "smart refresh layer".
  101.  *
  102.  * - IN_REFRESH      : Layer is currently being refreshed.
  103.  * - NEW_TO_REFRESH...
  104.  * - TO_REFRESH      : Layer needs a refresh.
  105.  * - NO_BACKFILL     : If an obscured layer part is made visible, this part
  106.  *                     is filled with the layer's background colour.  If this
  107.  *                     flag is set then no fill occurs.  This saves time if
  108.  *                     the part will be overwritten completely during refresh
  109.  *                     anyway (e.g. window border).
  110.  * - CLIPS_INVALID   : The layer was modified after this flag had been cleared
  111.  *                     the last time.  You can use this flag to put an addi-
  112.  *                     tional Clip region over the layer.
  113.  * - BACKDROP        : The layer lies behind all non-backdrop-layers.
  114.  */
  115.  
  116. /* Corresponding LayerFlagSet has 32 bits ! */
  117.  
  118. #define EL_SIMPLE_REFRESH (1<<0)
  119. #define EL_SUPER_BITMAP   (1<<1)
  120. #define EL_IN_REFRESH     (1<<2)
  121. #define EL_NEW_TO_REFRESH (1<<3)
  122. #define EL_TO_REFRESH     (1<<4)
  123. #define EL_NO_BACKFILL    (1<<5)
  124. #define EL_OBSOLETE1      (1<<6)
  125. #define EL_BACKDROP       (1<<7)
  126. #define EL_SMART_REFRESH  (1<<8)
  127.  
  128. typedef struct EL_LayerInfo *EL_LayerInfoPtr;
  129.  
  130. /*
  131.  * Layer, LayerPtr
  132.  *
  133.  * Structure for management of a layer.
  134.  *
  135.  * !!! READ-ONLY !!!
  136.  *
  137.  * .Front,
  138.  * .Back      : Chaining.
  139.  * .LayerInfo : Pointer to assigned "AreaInfo" structure.
  140.  * .MaxBorder : Maximum layer size in screen coordinates.
  141.  * .Border    : Maximum visible area of the layer on the screen.
  142.  * .FrontClip : Clip area for drawing onto the visible area.  The area is the
  143.  *              union of all specified ClipRects.
  144.  * .BackClip  : Clip area for drawing into the background BitMap (only for
  145.  *              super bitmap).  The border is specified in screen coordinates
  146.  *              and might be adjusted when necessary.
  147.  * .FrontMap  : Front Bitmap.
  148.  * .BackMap   : Background BitMap, NIL if missing.
  149.  * .Damage    : List of damaged screen areas.
  150.  * .Flags     : Flags (what else ?)
  151.  * .Lock      : Layer's lock.  A layer must be locked before using elements
  152.  *              from it since operations with other layers might change them.
  153.  * .Window    : Slave pointer pointing to the corresponding window.
  154.  * .ExtData   : PRIVATE !
  155.  * .BackColor : Background colour of the layer.
  156.  * .DispX,
  157.  * .DispY     : Coordinates of the top left point in layer coordinates.
  158.  * .Key       : Current refresh key (refer to "BeginUpdate").
  159.  * .ClipKey   : actuall version of the layer, is incremented by one by any
  160.  *              layer operation that modifies the cliprects.
  161.  * .BackHook  : Current hook for layer back fill operations.
  162.  *
  163.  *                               Layer, .MmaxBorder
  164.  *          DispX               /
  165.  *         /     \             /
  166.  *        /+-------------------------+
  167.  *  DispY| |                         |
  168.  *        \|     #############---------- visible area, .Border
  169.  *         |     #############       |
  170.  *         |     #############       |
  171.  *         |     #############       |
  172.  *         |     #############       |
  173.  *         |     #############       |
  174.  *         |     #############       |
  175.  *         |     #############       |
  176.  *         |     #############       |
  177.  *         |                         |
  178.  *         |                         |
  179.  *         +-------------------------+
  180.  *
  181.  * Layers should always be created and changed with the library functions as
  182.  * support for disk-based BitMaps will be added and the structure will be
  183.  * extended certainly.
  184.  */
  185.  
  186. typedef struct EL_SmartClip *EL_SmartPtr;
  187.  
  188. struct EL_SmartClip {                      /* PRIVATE */
  189.  
  190.     struct EB_ClipRect Cliprect;
  191.     E_EBitMapPtr       EMapp;
  192.     WORD               DispX, DispY;
  193.     E_EBitMapPtr       EMap;
  194. };
  195.  
  196. typedef struct EL_BackHook *EL_BackHookPtr;
  197.  
  198. /*
  199.  * EL_BackHook
  200.  *
  201.  * Descriptive structure for layer and layer info back fill function.
  202.  * Calling conventions are:
  203.  *
  204.  *  A0 map      : E_EBitMapPtr  : map to fill in
  205.  *  A1 UserData : APTR          : own user data from hook
  206.  *  D0 x        : WORD          : left edge of rectangle
  207.  *  D1 y        : WORD          : top edge of rectangle
  208.  *  D2 w        : WORD          : width of rectangle
  209.  *  D3 h        : WORD          : height of rectangle
  210.  *  D4 ox       : WORD          : left offset of rectangle in full rectangle
  211.  *  D5 oy       : WORD          : top offset of rectangle in full rectangle
  212.  *
  213.  * Use this structure only in conjunction with EL_InstallLHook and
  214.  * EL_InstallLIHook, never change the field in a layer or layerinfo structure
  215.  * directly.
  216.  *
  217.  */
  218.  
  219. struct EL_BackHook {
  220.     VOID   (*Call)();
  221.     APTR   UserData;
  222. };
  223.  
  224. typedef struct EL_Layer *EL_LayerPtr;
  225.  
  226. struct EL_Layer {
  227.  
  228.     EL_LayerPtr             front, back;
  229.     EL_LayerInfoPtr         LayerInfo;
  230.     struct EB_ClipRect      MaxBorder, Border;
  231.     EB_ClipRectPtr          FrontClip, BackClip;
  232.     E_EBitMapPtr            FrontMap, BackMap;
  233.     EB_ClipRectPtr          Damage;
  234.     EB_ClipRectPtr          FrontSave, BackSave;
  235.     ULONG                   Flags;
  236.     struct SignalSemaphore  Lock;
  237.     WORD                    Pad_1;
  238.     APTR                    Window;
  239.     APTR                    ExtData;
  240.     LONG                    BackColor;
  241.     WORD                    DispX, DispY;
  242.     LONG                    Key;
  243.     LONG                    ClipKey;
  244.     EL_BackHookPtr          BackHook;
  245. };
  246.  
  247.  
  248.  
  249. /*
  250.  * LayerInfo, LayerInfoPtr
  251.  *
  252.  * Interface structure between a BitMap and the layers that use it.  This
  253.  * structure must be created if layers are to be used.
  254.  *
  255.  * !!! READ-ONLY !!!
  256.  *
  257.  * .First        : Front layer on the screen.
  258.  * .Last         : Layer on the screen behind all other layers.
  259.  * .AllLocks     : Super-lock for all locks in the liste; if several layers
  260.  *                 of a screen are to be locked, this semaphore must be locked
  261.  *                 first (refer to "LockLayers" and "LockLayerInfo").
  262.  * .Map          : BitMap of that screen which the layers are belonging to.
  263.  * .Port         : Message port that refresh messages are sent to.
  264.  * .BackColor    : Background colour.
  265.  * .BackPattern  : Background pattern; if specified then the screen's back
  266.  *                 ground is filled with the pattern, otherwise the background
  267.  *                 colour is used.  The pattern can have any size, the size
  268.  *                 depends on its BitMap.
  269.  * .Border       : Border coordinates of the BitMap; a kind of ClipRect with
  270.  *                 highest priority.
  271.  *
  272.  * LayerInfo structures should always be created and changed with the library
  273.  * functions since it is possible that they are extended in future.
  274.  */
  275.  
  276. struct EL_LayerInfo {
  277.  
  278.     EL_LayerPtr             First, Last;
  279.     struct SignalSemaphore  Lock;
  280.     WORD                    Pad_1;
  281.     struct List             AllLocks;
  282.     WORD                    Pad_2;
  283.     E_EBitMapPtr            Map;
  284.     struct MsgPort         *Port;
  285.     LONG                    BackColor;
  286.     E_EBitMapPtr            BackPattern;
  287.     struct EB_ClipRect      Border;
  288.     EL_BackHookPtr          BackHook;
  289. };
  290.  
  291.  
  292.  
  293. /*
  294.  * LayerMsg, LayerMsgPtr
  295.  *
  296.  * Message that is sent when a layer wants refreshing.
  297.  *
  298.  * .Layer   : Layer to be refreshed.
  299.  * .Key     : Current refresh key of the layer (refer to "BeginUpdate").
  300.  *
  301.  * This message must be replied after having received it.
  302.  */
  303.  
  304. typedef struct EL_LayerMsg *EL_LayerMsgPtr;
  305.  
  306. struct EL_LayerMsg {
  307.     struct Message          Msg;
  308.     EL_LayerPtr             Layer;
  309.     LONG                    Key;
  310. };
  311.  
  312. #endif
  313.